# 该脚本用来将nodejs fetch的拷贝内容转换为burpsuite能够识别的内容
from fetch_parser import Parser


p = Parser()

"""
功能: 将fetch.js中的内容转换为bp格式的请求
"""
def fetch_to_bp():
    p.parse_file()
    print("%s %s HTTP/1.1" % (p.method, p.uri))
    print("Host: %s" % (p.host,))
    print("Content-Length: %d" % (len(p.body)))
    for key in p.headers:
        print("%s: %s" % (key, p.headers.get(key)))

    if p.method in ["POST", "PUT", "PATCH"]:
        print("\n" + p.body)
    print("\n")


if __name__ == "__main__":
    fetch_to_bp()

